local roushenguoguandao = fk.CreateSkill{
    name = "lingling__roushenguoguandao"
}
Fk:loadTranslationTable{
    ["lingling__roushenguoguandao"] = "肉神过管道",
    [":lingling__roushenguoguandao"] = "出牌阶段限一次，你可以表演“肉神过管道”，然后摸X张牌（X为获得的“星”数）。若表演成功，你随机获得一个<a href='lingling__roushenjianglin-href'>肉神专属技能</a>，至多获得三个。",
    ["#lingling__roushenguoguandao-prompt"] = "你可玩一次小游戏，成功后可获得技能",
    ["@lingling__roushenguoguandao1"] = "",
    ["@lingling__roushenguoguandao2"] = "",
    ["@lingling__roushenguoguandao3"] = "",
}
Fk:addMiniGame{
  name = "lingling__roushenguoguandao",
  qml_path = "packages/lingling/qml/roushenguoguandao",
  default_choice = function(player, data)
    return "false,0"
  end,
  update_func = function(player, data)
    local room = player.room
    if #data == 1 and data[1] == "confirm" then
        for _, p in ipairs(room:getOtherPlayers(player, false)) do
            p:doNotify("UpdateMiniGame", "")
        end
    else
        local dat = table.concat(data, ",")
        for _, p in ipairs(room:getOtherPlayers(player, false)) do
            p:doNotify("UpdateMiniGame", dat)
        end
    end
  end,
}
roushenguoguandao:addEffect("active",{
    prompt = "#lingling__roushenguoguandao-prompt",
    max_phase_use_time = 1,
    can_use = function (self, player)
        return self:withinTimesLimit(player,Player.HistoryPhase)
    end,
    card_num = 0,
    target_num = 0,
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,
    on_use = function (self, room, effect)
        local player = effect.from
        local data_table = {}
        for _, p in ipairs(room.players) do
            data_table[p.id] = {
                p == player,
            }
        end
        room:askToMiniGame(room.players, {
            skill_name = roushenguoguandao.name,
            game_type = "lingling__roushenguoguandao",
            data_table = data_table
        })
        local data = player.client_reply:split(",")
        if #data > 0 then
            local gameWin = data[1]
            local score = math.tointeger(tonumber(data[2]))
            if score and score > 0 then
                player:drawCards(score,roushenguoguandao.name)
            end
            if gameWin == "true" or gameWin == true then
                local skills = {"lingling__roushenmaomaoduo","lingling__roushenmaopaoshi","lingling__roushenyitong","lingling__roushenwuyingpai",
                "lingling__roushenzhuachuxue","lingling__roushenshuijiao","lingling__roushenfanying","lingling__roushendengyan",
                "lingling__roushenshoulie","lingling__roushenhuzhu","lingling__roushencaijianpan","lingling__roushendajiao",
                "lingling__roushenhoukongfan","lingling__roushenyao","lingling__roushenfuji","lingling__roushenlinghuo",
                "lingling__roushenzhaochide"}
                local skill = table.random(table.filter(skills,function (skill_name)
                    return not player:hasSkill(skill_name)
                end))
                room:handleAddLoseSkills(player,skill)
                local mark = player:getTableMark(roushenguoguandao.name)
                table.insertIfNeed(mark,skill)
                if #mark > 3 then
                    local removeSkill = room:askToChoice(player,{
                        choices = mark,
                        prompt = "肉神过管道：选择一个技能失去",
                        detailed = true,
                        skill_name = roushenguoguandao.name,
                    })
                    table.removeOne(mark,removeSkill)
                    room:handleAddLoseSkills(player,"-"..removeSkill)
                end
                for index, value in ipairs(mark) do
                    room:setPlayerMark(player,"@lingling__roushenguoguandao"..index,"<font color='burlywood'>"..Util.TranslateMapper(value).."</font>")
                end
                room:setPlayerMark(player,roushenguoguandao.name,mark)
            end
        end
    end,
})
local spec = {
    can_refresh = function (self, event, target, player, data)
        return player == target and player.general == "ling_friends__rourou" and data
    end,
    on_refresh = function (self, event, target, player, data)
        data.attachedSkillAndUser = data.attachedSkillAndUser or {}
        data.attachedSkillAndUser.muteCard = true
    end,
}
roushenguoguandao:addEffect(fk.PreCardUse,spec)
roushenguoguandao:addEffect(fk.PreCardRespond,spec)
return roushenguoguandao